<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <script>
                function title() {
                    document.getElementById('atendimento').className='selected';
                }
                window.onload=title;
            </script>
            <style>
                .ui-panel .ui-panel-titlebar-icon, .ui-panel .ui-panel-titlebar-icon:hover, .ui-panel .ui-panel-titlebar-icon:focus {
                    /*                    margin-top: -2.1em !important;*/
                }
            </style>
            <h:form id="diaryForm" enctype="multipart/form-data">
                <h1 class="title">
                    <a href="#" class="back" onclick="history.go(-1)"/>
                    Agenda
                </h1>
                <p:messages autoUpdate="true" id="messages" closable="true"/>

                <div class="row">
                    <div class="twelve columns">
                        <div class="container_24 clearfix ">
                            <p:commandButton icon="ui-icon-plusthick" value="Novo Agendamento" 
                                             actionListener="#{managerDiary.onDateSelect(null)}" update=":formDialog:eventDetails" 
                                             oncomplete="eventDialog.show();" style="position: absolute; margin-left: 16px; float:right;"
                                             process="@this"  />
                            <div class="clear"/>
                            <p:outputLabel value="Procedimento:" styleClass="grid_18" rendered="#{managerDiary.procedureSelect ne null}"/>
                            <p:autoComplete value="#{managerDiary.procedureSelect}" rendered="#{managerDiary.procedureSelect ne null}"
                                            id="selectProcedure" panelStyle="max-height: 200px;" 
                                            completeMethod="#{managerProcedure.autocomplete}"  
                                            var="p" itemLabel="#{p.name}" itemValue="#{p}" forceSelection="true"
                                            styleClass="grid_5" dropdown="true" 
                                            converter="#{autocompleteconverter}" >  
                                <p:ajax event="itemSelect" update="@form" process="@form" listener="#{managerDiary.selectProcedure()}"/>
                            </p:autoComplete>

                            <p:outputLabel value="Médico:" styleClass="grid_3" rendered="false"/>
                            <p:autoComplete value="#{managerDiary.doctorSelect}" rendered="false" 
                                            id="selectDoctor" completeMethod="#{managerDoctor.autocomplete}"  
                                            var="d" itemLabel="#{d.name}" itemValue="#{d}" forceSelection="true"
                                            styleClass="grid_5" dropdown="true" panelStyle="max-height:200px;" 
                                            converter="#{autocompleteconverter}" >  
                                <p:ajax event="itemSelect" update="@form" process="@form" listener="#{managerDiary.selectDoctor()}"/>
                            </p:autoComplete>
                            <div class="clear"/>

                            <div class="grid_13"></div>
                            <p:blockUI block="tabView" trigger="exibirtodos">
                                CARREGANDO<br />
                                <p:graphicImage value="/assets/images/ajax-loader.gif"/><br/>
                            </p:blockUI>
                            <p:outputLabel for="exibirtodos" value="Exibir Todos:" styleClass="grid_5"/>  
                            <p:selectBooleanCheckbox id="exibirtodos" styleClass="grid_3" value="#{managerDiary.exibeTodos}"  >
                                <p:ajax listener="#{managerDiary.loadAgenda()}" 
                                        oncomplete="myschedule.update();" 
                                        update="@form" process="@this"/>
                            </p:selectBooleanCheckbox>
                            <div class="clear"/>
                            <div class="grid_15"/>
                            <p:outputLabel for="doctorPesquisa" value="Médico:" styleClass="grid_3" rendered="#{managerDiary.doctorSelect ne null}"/>  
                            <p:inputText value="#{managerDiary.doctor.name}" rendered="#{managerDiary.doctorSelect ne null}"
                                         id="doctorPesquisa" readonly="true" onclick="dlgDoctorDialogPesquisa.show()"
                                         styleClass="grid_5" style="margin-right:0px;"/>

                            <p:commandButton  icon="ui-icon-plus" type="button"
                                              styleClass="ui-button-icon-only" 
                                              style="width: 25px; height: 28px; margin-left:0px;"
                                              title="Selecionar Médico" alt="Selecionar Médico"
                                              rendered="#{managerDiary.doctorSelect ne null}"
                                              onclick="dlgDoctorDialogPesquisa.show()"/>


                            <p:tabView id="tabView"   widgetVar="tabviewv"  dynamic="true" styleClass="grid_24">
                                <p:tab id="tba0" rendered="false" title="Hoje">

                                    <p:panel styleClass="grid_16" 
                                             style="background: none; border: none; ">
                                        <h5>Agendamentos de Hoje</h5>
                                        <p:poll onstart="myscheduleDay.update();" interval="15" />
                                        <p:schedule  id="scheduleday" locale="pt" slotMinutes="15"
                                                     timeZone="GMT-3" 
                                                     view="basicDay"  maxTime="21" minTime="6" 
                                                     showHeader="false"
                                                     value="#{managerDiary.eventModelHoje}" widgetVar="myscheduleDay"> 


                                            <p:ajax event="eventSelect" listener="#{managerDiary.onEventSelect}" 
                                                    update=":formDialog:eventDetails"
                                                    oncomplete="eventDialog.show();" />  


                                        </p:schedule>  



                                    </p:panel>

                                </p:tab>
                                <p:tab id="tba1" title="Calendário">


                                    <p:panel id="customerplain" style="background: none; border: none; width: 100%;" >


                                        <p:commandButton icon="ui-icon-refresh" title="Atualizar Agenda" alt="Atualizar Agenda"
                                                         style="height: 27px;margin-left: -5px; 
                                                         margin-top: 0; position: absolute; width: 31px;" 
                                                         onclick="myschedule.update();"
                                                         process="@this" rendered="false" />


                                        <p:poll onstart="myschedule.update();" interval="15" />
                                        <div class="grid_17">
                                            <p:calendar value="#{managerDiary.initialDate}" style="position: absolute" 
                                                        showOn="button" styleClass="grid_5" locale="pt" pattern="dd/MM/yyyy">
                                                <p:ajax event="dateSelect" update="@form" process="@form"/>
                                            </p:calendar>
                                            <div class="clear"/>
                                            <p:schedule  id="schedule" locale="pt" slotMinutes="15" 
                                                         view="#{managerDiary.exibeTodos ? 'basicDay':'agendaDay'}"
                                                         timeZone="GMT-3"
                                                         initialDate="#{managerDiary.initialDate}"
                                                         leftHeaderTemplate=""
                                                         rightHeaderTemplate="#{managerDiary.exibeTodos ?'':'month, agendaWeek, agendaDay' }"
                                                         value="#{managerDiary.eventModel}" widgetVar="myschedule">  

                                                <p:ajax event="dateSelect" listener="#{managerDiary.onDateSelect}" update=":formDialog:eventDetails" 
                                                        oncomplete="eventDialog.show();" />  

                                                <p:ajax event="eventSelect" listener="#{managerDiary.onEventSelect}" update=":formDialog:eventDetails"
                                                        oncomplete="eventDialog.show();" />  

                                                <p:ajax event="eventResize" listener="#{managerDiary.onEventResize}"  />  

                                            </p:schedule>  
                                        </div>
                                        <p:panel rendered="true"
                                                 header="Fila de Espera" styleClass="grid_6" 
                                                 style="margin-top: 2%; text-align: center; ">

                                            <p:button id="initialtreatment"  rendered="#{managerLayout.doctorByLogin}"
                                                      disabled="#{managerDiary.selectedWaitingLine.id eq null}" icon="ui-icon-clock"
                                                      value="Iniciar Atendimento" outcome="createRecords"
                                                      styleClass="grid_23 ui-priority-primary right">

                                                <f:param name="r" rendered="#{managerDiary.selectedWaitingLine.diary.retorno}" 
                                                         value="#{managerDiary.selectedWaitingLine.diary.retornoDiary.records.id}" />

                                                <f:param name="c" value="#{managerDiary.selectedWaitingLine.diary.customer.id}" />
                                                <f:param name="p" value="#{managerDiary.selectedWaitingLine.diary.procedure.id}" />
                                                <f:param name="d" value="#{managerDiary.selectedWaitingLine.diary.doctor.id}" />
                                                <f:param name="w" value="#{managerDiary.selectedWaitingLine.id}" />
                                                <f:param name="dw" value="#{managerDiary.selectedWaitingLine.diary.id}" />
                                            </p:button>
                                            <div class="clear"></div>
                                            <p:dataTable id="waitingList"  var="cus" rowIndexVar="cusindex"
                                                         emptyMessage="Não há pacientes" style="width: 100%;" 
                                                         rowKey="#{cus.id}" paginator="true" rows="10" paginatorPosition="bottom"
                                                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {NextPageLink} {LastPageLink}"  
                                                         selection="#{managerDiary.selectedWaitingLine}" selectionMode="single"
                                                         value="#{managerDiary.waitingLines}">  

                                                <p:ajax event="rowSelect" update=":diaryForm:tabView:initialtreatment" />  

                                                <p:column width="40">
                                                    <p:graphicImage  width="40" alt="#{cus.diary.customer.annex.id}" title="#{cus.diary.customer.annex.id}"
                                                                     url="#{cus.diary.customer.annex.id eq null ? '':'show/?annex='}#{cus.diary.customer.annex.id eq null ? 'assets/images/avatar.jpg':cus.diary.customer.annex.id}" />

                                                </p:column>
                                                <p:column width="100" style="text-align: left;">  
                                                    <h:outputText value="#{cus.diary.customer.name}" style="white-space: pre-wrap; "/>  
                                                </p:column>  
                                            </p:dataTable>


                                        </p:panel>

                                        <br/>
                                        <br/>
                                        <div class="grid_23">
                                            <h5>Legenda</h5>
                                            <div class="agendado grid_1"
                                                 style="height: 25px; width: 3%">
                                            </div>

                                            <div class="grid_2">
                                                Agendado
                                            </div>
                                            <div class="clear"/>
                                            <div class="confirmado fc-event-skin grid_1"
                                                 style="height: 25px;  width: 3%">
                                            </div>
                                            <div class="grid_3" style=" width: 7%">
                                                Confirmado
                                            </div>
                                            <div class="clear"/>
                                            <div class="cancelado fc-event-skin grid_1"
                                                 style="height: 25px;  width: 3%">
                                            </div>
                                            <div class="grid_2">
                                                Cancelado
                                            </div>
                                            <div class="clear"/>
                                            <div class="aguardando_atendimento fc-event-skin grid_1"
                                                 style="height: 25px;  width: 3%">
                                            </div>
                                            <div class="grid_8">
                                                Aguardando Atendimento
                                            </div>
                                            <div class="clear"/>
                                            <div class="atendimento_realizado fc-event-skin grid_1"
                                                 style="height: 25px;  width: 3%">
                                            </div>
                                            <div class="grid_8">
                                                Atendimento Realizado
                                            </div>
                                            <div class="clear"/>
                                        </div>
                                    </p:panel>
                                </p:tab>

                                <p:tab id="tba3" title="Pesquisar">
                                    <p:panel id="searchDiaryPanel"  style="background: none; border: none; width: 100%;" >
                                        <p:outputLabel for="nameCustomer" value="Nome:" styleClass="grid_3"/>
                                        <p:inputText id="nameCustomer" styleClass="grid_20" accesskey="70"
                                                     value="#{managerDiary.customerSearchDiary.name}"/>
                                        <p:outputLabel for="cpfCustomer" value="CPF:" styleClass="grid_3"/>
                                        <p:inputMask mask="999.999.999-99" id="cpfCustomer" styleClass="grid_20" accesskey="70"
                                                     value="#{managerDiary.customerSearchDiary.cpf}"/>

                                        <div class="buttonAction">
                                            <p:defaultCommand target="search-button-diary" />
                                            <p:commandButton id="search-button-diary" value="Pesquisar" icon="ui-icon-search"
                                                             update="searchDiaryPanel" process="searchDiaryPanel"
                                                             actionListener="#{managerDiary.findDiaryCustomer()}"
                                                             styleClass="ui-priority-primary" />
                                        </div >

                                        <p:dataTable id="searchDiary" var="sd" rowIndexVar="ddt"
                                                     paginator="true" rows="10" paginatorPosition="bottom"
                                                     value="#{managerDiary.diarysSearch}" emptyMessage="Nenhum registro encontrado" >

                                            <f:facet name="header">
                                                Resultados (#{managerDiary.diarysSearch.size()})
                                            </f:facet>

                                            <p:column headerText="Ação" width="35">
                                                <p:commandButton icon="ui-icon-search"  title="Visualizar Evento" alt="Visualizar Evento"
                                                                 actionListener="#{managerDiary.onEventSelectBasic(ddt)}"
                                                                 onclick="eventDialog.show();"
                                                                 process="@this" update=":formDialog:eventDetails"
                                                                 style="width: 25px; position: relative"/>
                                            </p:column>
                                            <p:column headerText="Data" style="white-space: pre-wrap;" width="75" sortBy="#{sd.startTime}">  
                                                <h:outputText value="#{sd.startTime}" >  
                                                    <f:convertDateTime pattern="dd/MM/yyy HH:mm:ss "  locale="pt"/>
                                                </h:outputText>
                                            </p:column>  

                                            <p:column headerText="Paciente" style="white-space: pre-wrap;" sortBy="#{sd.customer.name}">  
                                                <h:outputText value="#{sd.customer.name}" />  
                                            </p:column>

                                            <p:column headerText="Médico" style="white-space: pre-wrap;"  width="120">  
                                                <h:outputText value="#{sd.doctor.name}" />  
                                            </p:column>

                                            <p:column headerText="Convênio" style="white-space: pre-wrap;"  width="120">  
                                                <h:outputText value="#{sd.operator.name}" />  
                                            </p:column>

                                            <p:column headerText="Procedimento" style="white-space: pre-wrap;"  width="120">  
                                                <h:outputText value="#{sd.procedure.name}" />  
                                            </p:column>

                                        </p:dataTable>
                                    </p:panel>
                                </p:tab>
                            </p:tabView>
                            <p:dialog  widgetVar="dialogmsg" header="Alerta" modal="true"
                                       width="800" showEffect="clip" resizable="false" >
                                <p:messages autoUpdate="true"/>
                                <h2>#{managerDiary.msg}</h2> 
                            </p:dialog>
                            <p:dialog  widgetVar="fImprimir" header="Imprimir Folha de Rosto" modal="true"
                                       width="800" showEffect="clip" resizable="false" >

                                <p:ajax event="close" listener="#{managerDiary.cleanPrint()}" update="fPanelImprimir" /> 

                                <p:panel id="fPanelImprimir" style="background: none; border: none;" styleClass="container_24 clearfix " >
                                    <p:dataTable id="diarysPrint" var="print" paginator="true" rows="10"
                                                 paginatorPosition="bottom"
                                                 value="#{managerDiary.diarysDisp}"
                                                 rowKey="#{print.id}" selection="#{managerDiary.diarysSelected}" 
                                                 selectionMode="multiple">

                                        <p:ajax event="rowSelect"  process="@this" update="@this"/>
                                        <p:ajax event="rowUnselect"  process="@this" update="@this"/>

                                        <p:column headerText="Data">  
                                            <h:outputText value="#{print.startTime}" >  
                                                <f:convertDateTime pattern="dd/MM/yyyy à's' HH:mm:ss"/>
                                            </h:outputText>
                                        </p:column>  

                                        <p:column headerText="Situação" style="white-space: pre-wrap;" >  
                                            <h:outputText value="#{print.diarySituation.toString()}" />  
                                        </p:column>  

                                        <p:column headerText="Procedimento" style="white-space: pre-wrap;">  
                                            <h:outputText value="#{print.retorno ? 'Retorno - ':''}#{print.procedure.name}" />  
                                        </p:column>  

                                        <p:column headerText="Paciente" style="white-space: pre-wrap;">  
                                            <h:outputText value="#{print.customer.name}" />  
                                        </p:column>


                                    </p:dataTable>


                                </p:panel>
                                <f:facet name="footer" >
                                    <div class="grid_24 right">
                                        <p:commandButton 
                                            value="Imprimir" icon="ui-icon-print" immediate="true"
                                            ajax="false"  onclick="this.form.target='_blank'"
                                            styleClass="right" action="#{managerDiary.diaryReport()}"/>
                                    </div>
                                </f:facet>
                            </p:dialog>
                            <p:dialog  widgetVar="fDialog" header="Forma de Pagamento" modal="true"
                                       width="800" dynamic="true"  resizable="false" > 

                                <p:ajax event="close"  update="@this, :diaryForm:fPanel" /> 

                                <p:panel id="fPanel" style="background: none; border: none;" styleClass="container_24 clearfix " >

                                    <p:messages id="msgincome" autoUpdate="true" />


                                    <p:outputLabel value="" />
                                    <p:outputLabel for="procedureBasic" value="Procedimento" styleClass="grid_5"/>  
                                    <p:inputText value="#{managerDiary.procedure.name}" 
                                                 id="procedureBasic" readonly="true"  styleClass="grid_17"
                                                 style="margin-right:0px;"/>

                                    <p:outputLabel for="doctorBasic" value="Médico" styleClass="grid_5"/>  
                                    <p:inputText value="#{managerDiary.doctor.name}" 
                                                 id="doctorBasic" readonly="true"  styleClass="grid_17" style="margin-right:0px;"/>

                                    <p:outputLabel value="Forma de Pagamento" styleClass="grid_5"/> 
                                    <div class="grid_16">
                                        <p:selectOneMenu style="width: 108%;" panelStyle="width:150px;" 
                                                         value="#{managerDiary.income.paymentType}" >   
                                            <f:selectItems value="#{managerDiary.selectPaymentType()}" />
                                            <p:ajax update=":diaryForm:labelAmountMoney, :diaryForm:amountcard, :diaryForm:amountmoney, :diaryForm:labelAmountCard" />
                                        </p:selectOneMenu>
                                    </div>

                                    <p:outputLabel for="famount" value="Valor" styleClass="grid_5"/> 

                                    <p:inputText id="famount" styleClass="grid_17" 
                                                 value="#{managerDiary.income.amount}"
                                                 onkeypress="jQuery(this).autoNumeric({aSign:'R$ ', aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                        <p:ajax event="blur" update="@this, ftotalamount, famountpaid" 
                                                listener="#{managerDiary.calcDiscount()}"/>
                                    </p:inputText>

                                    <p:watermark value="R$" for="fdiscount"  />
                                    <p:watermark value="%" for="fdiscountpercent" />

                                    <p:outputLabel for="fdiscount" value="Desconto" styleClass="grid_5"/>  
                                    <p:inputText id="fdiscount" styleClass="grid_8" 
                                                 value="#{managerDiary.income.discount}"
                                                 onkeypress="jQuery(this).autoNumeric({aSign:'R$ ',aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                        <p:ajax event="blur" update="@this, ftotalamount, famountpaid" 
                                                listener="#{managerDiary.calcDiscount()}"/>
                                    </p:inputText>

                                    <p:inputText styleClass="grid_9" 
                                                 id="fdiscountpercent"
                                                 style="width: 34.1%"
                                                 onkeypress="jQuery(this).autoNumeric({pSign: 's',aSign: '%', aSep: '.', aDec: ','} );"
                                                 value="#{managerDiary.discount}"  >
                                        <f:convertNumber type="percent"  locale="pt,BR"  />
                                        <p:ajax event="blur" update="@this, ftotalamount, famountpaid, fdiscount" 
                                                listener="#{managerDiary.calcDiscountPorce()}"/>
                                    </p:inputText>

                                    <div class="clear"/>

                                    <p:watermark value="Dinheiro" for="amountmoney"  />
                                    <p:watermark value="Cartão" for="amountcard" />

                                    <p:outputLabel id="labelAmountMoney"  for="amountmoney" 
                                                   value="Valor Dinheiro:" styleClass="grid_5" style="display: #{managerDiary.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}"/>  
                                    <p:inputText  style="display: #{managerDiary.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}" 
                                                  id="amountmoney" styleClass="grid_6" 
                                                  value="#{managerDiary.income.amountMoney}"
                                                  onkeypress="jQuery(this).autoNumeric({aSign:'R$ ',aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                    </p:inputText>

                                    <p:outputLabel id="labelAmountCard"  for="amountcard" 
                                                   value="Valor Cartão:" styleClass="grid_4" style="display: #{managerDiary.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}"/>  


                                    <p:inputText  style="display: #{managerDiary.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}; width: 26%;" 
                                                  id="amountcard" styleClass="grid_6" 
                                                  value="#{managerDiary.income.amountCard}"
                                                  onkeypress="jQuery(this).autoNumeric({aSign:'R$ ',aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                    </p:inputText>

                                    <div class="clear"/>

                                    <p:outputLabel for="ftotalamount" value="Valor Total" styleClass="grid_5"/>  
                                    <p:inputText id="ftotalamount" styleClass="grid_17"  readonly="true" disabled="true"
                                                 value="#{managerDiary.income.totalAmount}"
                                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                        <f:convertNumber pattern="#,###,##0.00"/>
                                    </p:inputText>

                                    <p:outputLabel for="famountpaid" value="Valor Pago" styleClass="grid_5"/>  
                                    <p:inputText id="famountpaid" styleClass="grid_8" 
                                                 value="#{managerDiary.income.amountPaid}"
                                                 onkeypress="jQuery(this).autoNumeric({aSign:'R$ ', aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                    </p:inputText>


                                    <p:outputLabel for="dateincome" value="Em:" styleClass="grid_2" style="width: 5%;"/>  
                                    <p:calendar id="dateincome" value="#{managerDiary.income.createAt}" 
                                                showOn="button" styleClass="grid_7" pattern="dd/MM/yyyy HH:mm" locale="pt"/>  


                                    <div class="clear"/>
                                    <h:outputLabel rendered="#{managerDiary.income.systemUser ne null}" value="Recebido por: #{managerDiary.income.systemUser.name}" 
                                                   styleClass="grid_15" style="text-align: right;"/>
                                    <h:outputLabel rendered="#{managerDiary.income.systemUser ne null}" value="em: " styleClass="grid_1" style="text-align: right;"/>
                                    <h:outputLabel rendered="#{managerDiary.income.systemUser ne null}" value="#{managerDiary.income.createAt}" styleClass="grid_5">
                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                    </h:outputLabel>

                                    <div class="clear"/>

                                    <div class="buttonAction">
                                        <p:commandButton icon="ui-icon-close" process="@this, fPanel" update="@this, fPanel"
                                                         value="Cancelar" disabled="#{managerDiary.income.id eq null}"
                                                         actionListener="#{managerDiary.clearIncome()}"
                                                         oncomplete="fDialog.hide();"/>

                                        <p:commandButton icon="ui-icon-check" process="@this, fPanel" update="@this, fPanel"
                                                         disabled="#{managerDiary.diary.diarySituation ne 'CALL_WAITING'}"
                                                         value="Confirmar" actionListener="#{managerDiary.saveIncome()}"
                                                         styleClass="ui-priority-primary"/>
                                    </div>
                                </p:panel>
                            </p:dialog>

                        </div>
                    </div>
                </div>
            </h:form>

            <h:form id="formDialog">

                <p:dialog id="eventD"  widgetVar="eventDialog" header="Atendimento" 
                          modal="true" resizable="false" dynamic="true" closeOnEscape="true"
                          width="1000"  height="500" > 

                    <p:ajax event="close" listener="#{managerDiary.clean()}" update="eventD, :formDialog:tabViewCustomer" /> 
                    <p:messages autoUpdate="true" closable="true"/>

                    <p:panel id="eventDetails" style="background: none; border: none; margin-top: -25px;" styleClass="container_24 clearfix " >

                        <div class="grid_6" style="text-align: center;">
                            <br/>
                            <p:panel header="Paciente" styleClass="grid_22" style="text-align: center;font-size: 12px;">
                                <p:graphicImage id="avatar1" styleClass="image grid_3" 
                                                style="margin-left:2%; width: 150px;" 
                                                alt="#{managerDiary.customer.annex.id}" title="#{managerDiary.customer.annex.id}"
                                                url="#{managerDiary.customer.annex.id eq null ? '':'show/?annex='}#{managerDiary.customer.annex.id eq null ? 'assets/images/avatar.jpg': managerDiary.customer.annex.id}" />
                            </p:panel>

                            <div class="clear"></div>

                            <p:panel header="Ações" styleClass="grid_22" style="text-align: center;font-size: 12px;">

                                <div class="grid_24" style="text-align: left; ">

                                    <div class="clear"></div>


                                    <p:commandButton  icon="ui-icon-plus" 
                                                      value="Adicionar Paciente" type="button"
                                                      title="Adicionar Paciente" alt="Adicionar Paciente"
                                                      styleClass="grid_24 ui-priority-primary" 
                                                      onclick="dlgCustomerDialog.show()"/>

                                    <p:commandButton  icon="ui-icon-pencil" 
                                                      rendered="#{managerDiary.customer.id ne null}"
                                                      value="Atualizar informações" type="button" 
                                                      title="Atualizar informações" alt="Atualizar Informações"
                                                      styleClass="grid_24" onclick="dlgCustomerDialog.show();lazyselect()" />

                                    <p:remoteCommand name="lazyselect" update=":formDialog:tabViewCustomer" 
                                                     process="@this" actionListener="#{managerDiary.loadEditCustomer()}"
                                                     oncomplete="wgvTabViewCustomer.select(2);"/> 

                                    <div class="clear"></div>

                                    <p:commandButton id="relPrint" rendered="#{managerDiary.diary.id != null}"
                                                     value="Imprimir" immediate="true" icon="ui-icon-print" 
                                                     update=":diaryForm:fPanelImprimir, :diaryForm:diarysPrint"
                                                     actionListener="#{managerDiary.verifyOtherDiary()}"
                                                     oncomplete="fImprimir.show();"
                                                     styleClass="grid_24" />

                                    <p:button rendered="#{managerDiary.diary.diarySituation.toString() eq 'Aguardando Atendimento' ? true:false}" icon="ui-icon-clock"
                                              value="Iniciar Atendimento" outcome="createRecords"
                                              disabled="#{managerDiary.diary.records ne null}"
                                              styleClass="ui-priority-primary grid_24">
                                        <f:param name="r" rendered="#{managerDiary.diary.retorno}" 
                                                 value="#{managerDiary.diary.retornoDiary.records.id}" />
                                        <f:param name="c" value="#{managerDiary.customer.id}" />
                                        <f:param name="p" value="#{managerDiary.procedure.id}" />
                                        <f:param name="d" value="#{managerDiary.doctor.id}" />
                                        <f:param name="dw" value="#{managerDiary.diary.id}" />
                                    </p:button>

                                    <p:button rendered="#{managerDiary.diary.records.id ne null}"
                                              icon="ui-icon-clock"
                                              value="Visualizar Atendimento" outcome="createRecords"
                                              styleClass="ui-priority-primary grid_24">
                                        <f:param name="r" value="#{managerDiary.diary.records.id}" />
                                        <f:param name="c" value="#{managerDiary.customer.id}" />
                                        <f:param name="p" value="#{managerDiary.procedure.id}" />
                                        <f:param name="d" value="#{managerDiary.doctor.id}" />
                                    </p:button>

                                    <p:commandButton id="fBtnDlg" 
                                                     value="Financeiro" process="@this"
                                                     update="@this, :diaryForm:fPanel" icon="ui-icon-cart"
                                                     oncomplete="fDialog.show();" actionListener="#{managerDiary.incomeDlg()}"
                                                     styleClass="grid_24" />
                                </div>


                            </p:panel>
                            <p:panel header="Informações do Atendimento" styleClass="grid_22" 
                                     style="text-align: left; font-size: 10px;" collapsed="true" toggleable="true">
                                <h:outputText  value="Cadastrado por:" styleClass="grid_24" 
                                               style="font-weight: bold; "/>
                                <h:outputText rendered="#{managerDiary.diary.systemUser ne null}"
                                              value="#{managerDiary.diary.systemUser.name} às " />
                                <h:outputText rendered="#{managerDiary.diary.systemUser ne null}" 
                                              value="#{managerDiary.diary.createAt}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>

                                <hr style="margin: 5px;"/>
                                <h:outputText  value="Atualizado por:" styleClass="grid_24" 
                                               style="font-weight: bold; "/>

                                <h:outputText rendered="#{managerDiary.diary.systemUserUpdate ne null}"
                                              value="#{managerDiary.diary.systemUserUpdate.name} às " />
                                <h:outputText rendered="#{managerDiary.diary.systemUserUpdate ne null}" 
                                              value="#{managerDiary.diary.updateAt}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>

                                <hr style="margin: 5px;"/>
                                <h:outputText  value="Pagamento recebido por:" styleClass="grid_24" 
                                               style="font-weight: bold; "/>
                                <h:outputText rendered="#{managerDiary.income.systemUser ne null}"
                                              value="#{managerDiary.income.systemUser.name} às " />
                                <h:outputText rendered="#{managerDiary.income.systemUser ne null}" 
                                              value="#{managerDiary.income.createAt}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>

                                <hr style="margin: 5px;"/>
                                <h:outputText  value="Atendimento realizado por:" styleClass="grid_24" 
                                               style="font-weight: bold; "/>
                                <h:outputText rendered="#{managerDiary.diary.records ne null}" 
                                              value="#{managerDiary.diary.records.systemUser.name}" />
                                <h:outputText rendered="#{managerDiary.diary.records ne null}" 
                                              value="#{managerDiary.diary.records.createAt}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>
                            </p:panel>
                        </div>
                        <div class="grid_18">

                            <p:tabView id="tabView" >
                                <p:tab id="tba1" title="Consulta/Procedimento" >
                                    <p:panel id="panelatendimento" style="background: none; border: none; margin: 0px;"
                                             styleClass="container_24 clearfix">


                                        <div class="ui-messages ui-widget" style="display: #{managerDiary.pacienteAniversario() ne null ? 'block':'none'}">
                                            <div class="ui-messages-warn ui-corner-all">
                                                <span class="ui-messages-warn-icon"/>
                                                <ul>       
                                                    <li>
                                                        <span class="ui-messages-warn-summary">
                                                            <h:outputText value="#{managerDiary.pacienteAniversario()}"/>
                                                        </span>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>

                                        <h5>Paciente</h5>
                                        <hr style="margin-top: 0px;"/>

                                        <p:outputLabel for="customer" value="Nome:" styleClass="grid_4"/>  
                                        <p:inputText value="#{managerDiary.customer.name}"  id="customer" disabled="true" 
                                                     styleClass="grid_7"/>

                                        <p:outputLabel for="customercpf" value="CPF:" styleClass="grid_4"/>  

                                        <p:inputMask id="customercpf" mask="999.999.999-99" styleClass="grid_8" 
                                                     value="#{managerDiary.customer.cpf}"  readonly="true"
                                                     disabled="true">
                                            <p:ajax event="blur" process="@this"/>
                                        </p:inputMask>

                                        <div class="clear"/>

                                        <p:outputLabel for="dataNasc" value="Nascimento:" styleClass="grid_4"/>
                                        <p:calendar id="dataNasc" showOn="button" 
                                                    style=" width: 27.3%"  styleClass="grid_7"
                                                    pattern="dd/MM/yyyy" locale="pt"  disabled="true" 
                                                    value="#{managerDiary.customer.dateBirth}"/>

                                        <p:outputLabel value="Sexo: " for="selectGender" styleClass="grid_4"  style="width: 16.2%;"/>
                                        <div class="grid_7">
                                            <p:selectOneMenu id="selectGender"  
                                                             style="width: 119.5%; height: 26px;" 
                                                             disabled="true"
                                                             panelStyle="width:100.5px;" value="#{managerDiary.gender}" > 

                                                <f:ajax listener="#{managerDiary.saveGender()}" />

                                                <f:selectItem itemLabel="Masculino" itemValue="#{true}" />
                                                <f:selectItem itemLabel="Feminino" itemValue="#{false}" />
                                            </p:selectOneMenu>
                                        </div>

                                        <div class="clear"/>

                                        <p:outputLabel  value="Telefone:" for="inputTelefone" styleClass="grid_4"/>  
                                        <p:inputMask id="inputTelefone" mask="(99) 9999-9999" styleClass="grid_7" 
                                                     disabled="true" 
                                                     value="#{managerDiary.customer.phone}" />


                                        <p:outputLabel value="Celular:" for="inputCelular" styleClass="grid_4"/> 
                                        <p:inputMask id="inputCelular" mask="(99) 9999-9999"
                                                     styleClass="grid_8"  disabled="true" 
                                                     value="#{managerDiary.customer.cellular}" />

                                        <div class="clear"/>
                                        <p:outputLabel for="operator" value="Convênio:" styleClass="grid_4"/>
                                        <p:inputText value="#{managerDiary.operator.name}" 
                                                     id="operator" readonly="true"  styleClass="grid_17" 
                                                     disabled="#{managerDiary.operator.id eq null ? true:false}"
                                                     style="margin-right:0px; width:#{managerDiary.operator.id ne null ? '69%':'74%'};"/>
                                        <p:commandButton  icon="ui-icon-plus" process="@this" immediate="true"
                                                          styleClass="ui-button-icon-only"  type="button" 
                                                          title="Adicionar Convênio" alt="Adicionar Convênio"
                                                          style="width: 25px; height: 28px; margin-left:0px;" 
                                                          onclick="dlgOperatorDialog.show();"/>

                                        <p:commandButton  icon="ui-icon-trash" 
                                                          rendered="#{managerDiary.operator.id ne null ? true:false}"
                                                          title="Remover Convênio" alt="Remover Convênio"
                                                          update=":formDialog:eventDetails" 
                                                          process="@this" styleClass="ui-button-icon-only" 
                                                          style="width: 25px; height: 28px; margin-left:30px;" 
                                                          immediate="false" actionListener="#{managerDiary.clearOperator()}" />


                                        <div class="clear"/>

                                        <h5>Procedimento</h5>
                                        <hr style="margin-top: 0px;"/>

                                        <p:outputLabel for="retorno" value="É Retorno ?:" styleClass="grid_4"/>
                                        <div class="grid_1">
                                            <h:selectBooleanCheckbox id="retorno" 
                                                                     value="#{managerDiary.diary.retorno}"  > 
                                                <p:ajax listener="#{managerDiary.loadRetorno()}" update="labelretorno, :formDialog:procedureRetornoPanel"/>
                                            </h:selectBooleanCheckbox>
                                        </div>
                                        <p:outputLabel id="labelretorno" value="#{managerDiary.strRetorno}" style="color:red;" 
                                                       styleClass="grid_7"/>
                                        <div class="clear"/>

                                        <p:outputLabel for="procedure" value="Procedimento:" styleClass="grid_4"/>  
                                        <p:inputText value="#{managerDiary.procedure.name}" 
                                                     disabled="#{managerDiary.procedure.id eq null ? true:false}"
                                                     id="procedure" readonly="true"  styleClass="grid_18" style="margin-right:0px;"/>

                                        <p:commandButton  icon="ui-icon-plus" process="@this" immediate="true"
                                                          styleClass="ui-button-icon-only"  type="button" 
                                                          style="width: 25px; height: 28px; margin-left:0px;" 
                                                          title="Adicionar Procedimento" alt="Adicionar Procedimento"
                                                          onclick="dlgProcedureDialog.show();"/>

                                        <p:commandButton  icon="ui-icon-trash"
                                                          rendered="#{managerDiary.procedure.id ne null ? true:false}"
                                                          title="Remover Procedimento" alt="Remover Procedimento"
                                                          update=":formDialog:eventDetails" 
                                                          process="@this" styleClass="ui-button-icon-only" 
                                                          style="width: 25px; height: 28px; margin-left:2px;" 
                                                          immediate="false" actionListener="#{managerDiary.clearProcedure()}" />

                                        <p:commandButton id="btnrecomendacao"  icon="ui-icon-info"
                                                         rendered="#{managerDiary.procedure.id ne null ? true:false}"
                                                         title="Recomendações" alt="Recomendações"
                                                         process="@this" styleClass="ui-button-icon-only" 
                                                         style="width: 25px; height: 28px; margin-left:32px;" 
                                                         type="button" immediate="true" onclick="dlgrecomendacao.show();" />

                                        <p:dialog header="Recomendações" closeOnEscape="escape"
                                                  resizable="false"
                                                  widgetVar="dlgrecomendacao" minHeight="200" minWidth="200">
                                            <p:panel>
                                                <h:outputText escape="false" value="#{managerDiary.procedure.recomendacao}" />
                                            </p:panel>
                                        </p:dialog>

                                        <div class="clear"/>
                                        <p:outputLabel for="doctor" value="Médico Resp.:" styleClass="grid_4"/>  
                                        <p:inputText value="#{managerDiary.doctor.name}" 
                                                     disabled="#{managerDiary.doctor.id eq null ? true:false}"
                                                     id="doctor" readonly="true"  styleClass="grid_18" style="margin-right:0px;"/>

                                        <p:commandButton  icon="ui-icon-plus" type="button"
                                                          styleClass="ui-button-icon-only" 
                                                          style="width: 25px; height: 28px; margin-left:0px;" 
                                                          title="Adicionar Médico Responsável" alt="Adicionar Médico Responsável"
                                                          onclick="dlgDoctorDialog.show()"/>

                                        <p:commandButton  icon="ui-icon-trash"
                                                          rendered="#{managerDiary.doctor.id ne null ? true:false}"
                                                          title="Remover Médico Responsável" alt="Remover Médico Responsável"
                                                          update=":formDialog:eventDetails" 
                                                          process="@this"   styleClass="ui-button-icon-only" 
                                                          style="width: 25px; height: 28px; margin-left:2px;"
                                                          immediate="false" actionListener="#{managerDiary.clearDoctor()}" />



                                        <div class="clear"/>
                                        <p:outputLabel for="doctorRequest" value="Médico Solic.:" styleClass="grid_4"/>  
                                        <p:inputText value="#{managerDiary.doctorRequest.name}" 
                                                     disabled="#{managerDiary.doctorRequest.id eq null ? true:false}"
                                                     id="doctorRequest" readonly="true" 
                                                     styleClass="grid_18" style="margin-right:0px;"/>

                                        <p:commandButton  icon="ui-icon-plus" type="button"
                                                          styleClass="ui-button-icon-only" 
                                                          style="width: 25px; height: 28px; margin-left:0px;"
                                                          title="Adicionar Médico Solicitante" alt="Adicionar Médico Solicitante"
                                                          onclick="dlgDoctorRequestDialog.show()"/>

                                        <p:commandButton  icon="ui-icon-trash"
                                                          rendered="#{managerDiary.doctorRequest.id ne null ? true:false}"
                                                          title="Remover Médico Solicitante" alt="Remover Médico Solicitante"
                                                          update=":formDialog:eventDetails" 
                                                          process="@this"   styleClass="ui-button-icon-only" 
                                                          style="width: 25px; height: 28px; margin-left:2px;"
                                                          immediate="false" actionListener="#{managerDiary.clearDoctorRequest()}" />


                                        <div class="clear"/>

                                        <h5>Horário</h5>
                                        <hr style="margin-top: 0px;"/>

                                        <p:outputLabel for="selectSituacao" value="Situação:" styleClass="grid_4"/>
                                        <div class="grid_19">
                                            <p:selectOneMenu id="selectSituacao" style="width: 102%;" value="#{managerDiary.diary.diarySituation}" >   
                                                <f:selectItem itemLabel="" itemValue="" />  
                                                <f:selectItems value="#{managerDiary.selectTypeDiary()}" />
                                                <p:ajax update="@this, :formDialog:eventDetails, :diaryForm:tabView:waitingList, :diaryForm:famount, :diaryForm:ftotalamount, :diaryForm:famountpaid" 
                                                        process="@this, :formDialog:eventDetails"
                                                        listener="#{managerDiary.updateStatusEvent()}" />
                                            </p:selectOneMenu> 
                                        </div>

                                        <div class="clear"></div>
                                        <p:outputLabel for="dateDiary" rendered="false" value="Data" styleClass="grid_4"/>
                                        <p:calendar id="dateDiary" showOn="button" styleClass="grid_18" rendered="false"
                                                    value="#{managerDiary.diary.dateConsultation}"
                                                    pattern="dd/MM/yyyy" locale="pt" required="true"/>

                                        <p:outputLabel for="from" value="De:" styleClass="grid_4"/>  
                                        <p:calendar id="from" value="#{managerDiary.event.startDate}" 
                                                    showOn="button" styleClass="grid_7" pattern="dd/MM/yyyy HH:mm"
                                                    required="true" locale="pt"/>  

                                        <p:outputLabel for="to" value="Até:" styleClass="grid_4"/>  
                                        <p:calendar id="to" value="#{managerDiary.event.endDate}" 
                                                    showOn="button" styleClass="grid_7" style="width: 29.767%;"
                                                    pattern="dd/MM/yyyy HH:mm"  locale="pt" 
                                                    required="true"/>  
                                        <div class="clear"></div>
                                        <p:outputLabel for="obs" value="Observações:" styleClass="grid_4"/>  
                                        <p:inputText id="obs" value="#{managerDiary.diary.observation}" 
                                                     styleClass="grid_19" /> 
                                        <div class="clear"></div>

                                        <div class="buttonAction" style="margin: 0;">
                                            <p:commandButton id="addButton" 
                                                             value="#{managerDiary.diary.id ne null ? 'Atualizar':'Salvar'}" 
                                                             process=":formDialog:eventDetails" update=":formDialog:eventDetails"
                                                             actionListener="#{managerDiary.addEvent}"
                                                             styleClass="ui-priority-primary"
                                                             icon="ui-icon-disk"/>  
                                            <p:commandButton process="@this" update="@this" value="Cancelar" onclick="eventDialog.hide();" />  
                                        </div>
                                        <div class="clear"></div>

                                    </p:panel>
                                </p:tab>
                                <p:tab id="tba3"  title="#{managerDiary.verificaAtividadeRecente()} Atividades Recentes #{managerDiary.existeAtividadeRecente ? '*':'-'}"
                                       titleStyleClass="#{managerDiary.existeAtividadeRecente ? 'atividadeRecente':''}" >

                                    <h:outputText rendered="#{!managerDiary.existeAtividadeRecente}" 
                                                  value="Nenhuma Atividade Recente" />

                                    <ui:repeat value="#{managerDiary.listAtendimentosHoje}" var="lah">
                                        <div class="ui-messages ui-widget" style="display: #{managerDiary.msg ne null ? 'block':'none'}">
                                            <div class="ui-messages-warn ui-corner-all">
                                                <span class="ui-messages-warn-icon"/>
                                                <ul>       
                                                    <li>
                                                        <span class="ui-messages-warn-summary">
                                                            <h:outputText value="#{lah.diarySituation.toString()}: "/>
                                                            <h:outputText value="#{lah.procedure.name} às " escape="false"/>
                                                            <h:outputText value="#{lah.startTime}" >
                                                                <f:convertDateTime pattern="HH:mm:ss" />
                                                            </h:outputText>
                                                        </span>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </ui:repeat>
                                    <div class="ui-messages ui-widget" style="display: #{managerDiary.msg ne null ? 'block':'none'}">
                                        <div class="ui-messages-warn ui-corner-all">
                                            <span class="ui-messages-warn-icon"/>
                                            <ul>                                                            
                                                <h:outputText value="#{managerDiary.msg}" escape="false"/>
                                            </ul>
                                        </div>
                                    </div>

                                    <p:dataTable id="searchDiary"  var="sd" 
                                                 rowIndexVar="ddt" emptyMessage="Nenhum Agendamento Realizado"
                                                 paginator="true" rows="10" paginatorPosition="bottom"
                                                 value="#{managerDiary.diarysRecents}"  >

                                        <f:facet name="header">
                                            Agendamentos (#{managerDiary.diarysRecents.size()})
                                        </f:facet>
                                        <p:column headerText="Data" style="white-space: pre-wrap;" width="75">  
                                            <h:outputText value="#{sd.startTime}" >  
                                                <f:convertDateTime pattern="dd/MM/yyy HH:mm:ss "  locale="pt"/>
                                            </h:outputText>
                                        </p:column>

                                        <p:column headerText="Status" style="white-space: pre-wrap;" width="120">  
                                            <h:outputText value="#{sd.diarySituation.toString()}" />  
                                        </p:column>

                                        <p:column headerText="Médico">  
                                            <h:outputText value="#{sd.doctor.name}" />  
                                        </p:column>

                                        <p:column headerText="Procedimento">  
                                            <h:outputText value="#{sd.procedure.name}" />  
                                        </p:column>

                                    </p:dataTable>
                                </p:tab>

                                <p:tab title="#{managerDiary.getHistoryRecords()}Histórico Clínico">
                                    <ui:repeat value="#{managerDiary.recordses}" var="r">
                                        #{managerAtendimento.diaryPorRecord(r.id)}
                                        <div class="container_24 clearfix">
                                            <div class="grid_3">
                                                <p class="date">
                                                    <a href="#">
                                                        <h:outputText value="#{r.createAt}">
                                                            <f:convertDateTime pattern="MMMMM" />
                                                        </h:outputText>
                                                        <b>
                                                            <h:outputText value="#{r.createAt}">
                                                                <f:convertDateTime pattern="dd"/>
                                                            </h:outputText>

                                                        </b>
                                                        <span>
                                                            <h:outputText value="#{r.createAt}">
                                                                <f:convertDateTime pattern="yyyy"/>
                                                            </h:outputText>
                                                        </span>
                                                    </a>
                                                </p>
                                            </div>
                                            <p:panel style="background: none; margin:none;" 
                                                     styleClass="grid_20" 
                                                     collapsed="#{managerAtendimento.collapsed}"  toggleable="#{managerLayout.doctorByLogin}">

                                                <f:facet name="header">
                                                    <div class="grid_22 clearfix">

                                                        <div class="grid_18">
                                                            <h:outputText value="#{r.procedure.typeProcedure.name}:" styleClass="grid_5"/>
                                                            <h:outputText value="#{r.procedure.typeProcedure.name} #{r.procedure.name}" 
                                                                          styleClass="grid_19"/>
                                                            <div class="clear"/>
                                                            <h:outputText value="Médico:" styleClass="grid_5"/>
                                                            <h:outputText value="#{r.doctor.name}" styleClass="grid_13"/>
                                                            <div class="clear"/>
                                                            <h:outputText value="Médico Solicitante:" styleClass="grid_10" rendered="false"/>
                                                            <h:outputLabel value="#{managerAtendimento.diaryrecord ne null ? managerAtendimento.diaryrecord.doctorRequest.name:' - '}" 
                                                                           styleClass="grid_13"  rendered="false"/>
                                                            <div class="clear"/>
                                                            <h:outputText value="Convênio:" styleClass="grid_5"  rendered="false"/>
                                                            <h:outputText value="#{managerAtendimento.diaryrecord ne null ? managerAtendimento.diaryrecord.operator.name :' - '}" 
                                                                          styleClass="grid_13"  rendered="false"/>
                                                        </div>
                                                        <p:button icon="ui-icon-arrowreturnthick-1-w" 
                                                                  value="Retorno" outcome="createRecords"
                                                                  rendered="#{managerLayout.doctorByLogin}"
                                                                  styleClass="grid_5">
                                                            <f:param name="c" value="#{r.customer.id}" />
                                                            <f:param name="r" value="#{r.id}" />
                                                            <f:param name="p" value="#{r.procedure eq null ? null : r.procedure.id}" />
                                                            <f:param name="d" value="#{r.doctor eq null ? null : r.doctor.id}" />
                                                        </p:button>
                                                    </div>
                                                </f:facet>

                                                <div class="grid_20" >
                                                    <div style="display: #{managerAtendimento.showAnamnese ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Anamnese</h4>

                                                        <ui:repeat value="#{r.anamneses}" var="ra">
                                                            <p:outputLabel value="Queixa Principal#{ra.id}" styleClass="grid_5"/>
                                                            <p:inputText styleClass="grid_18" readonly="true" value="#{ra.chiefComplaint}"/>
                                                            <div class="clear"/>
                                                            <p:outputLabel value="História" styleClass="grid_5"/>
                                                            <div class="grid_18">
                                                                <p:inputTextarea readonly="true" value="#{ra.descr}"/>
                                                            </div>
                                                        </ui:repeat>
                                                        <p:outputLabel value="Queixa Principal" styleClass="grid_5" rendered="#{empty r.anamneses}"/>
                                                        <p:inputText styleClass="grid_18" readonly="true" rendered="#{empty r.anamneses}"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="História" styleClass="grid_5" rendered="#{empty r.anamneses}"/>
                                                        <div class="grid_18">
                                                            <p:inputTextarea readonly="true" rendered="#{empty r.anamneses}"/>
                                                        </div>

                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showExameFisico ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Exame Físico</h4>

                                                        <div class="clear"/>
                                                        <p:outputLabel value="Altura" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.height}"/>
                                                        <p:outputLabel value="m" styleClass="grid_1"/>
                                                        <p:outputLabel value="Peso" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.weight}"/>
                                                        <p:outputLabel value="kg" styleClass="grid_1"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Batimento Cardíaco" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.heartRate}"/>
                                                        <p:outputLabel value="bpm" styleClass="grid_1"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Pressão arterial sistólica" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.systolicPressure}"/>
                                                        <p:outputLabel value="mmHg" styleClass="grid_1"/>
                                                        <p:outputLabel value="Pressão arterial Diastólica" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.diastolicPressure}"/>
                                                        <p:outputLabel value="mmHg" styleClass="grid_1"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Observações" styleClass="grid_5"/>
                                                        <div class="grid_19">
                                                            <p:inputTextarea readonly="true" value="#{r.physicalExamination.descr}"/>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showDiagnostico ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Diagnóstico</h4>

                                                        <p:outputLabel value="Diagnóstico" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_18" readonly="true" value="#{r.diagnostic.cid}"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Conduta" styleClass="grid_5"/>
                                                        <div class="grid_18">
                                                            <p:inputTextarea readonly="true" value="#{r.diagnostic.descr}"/>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showReceituario ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Receituário</h4>
                                                        <p:outputLabel value="Descrição" styleClass="grid_5"/>
                                                        <div class="grid_18">
                                                            <p:inputTextarea readonly="true" value="#{r.prescription}"/>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showEvolucao ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Evolução/Retorno</h4>


                                                        <ui:repeat value="#{r.evolutions}" var="ev">

                                                            <div class="grid_6">
                                                                <p class="date">
                                                                    <a href="#">
                                                                        <h:outputText value="#{ev.dateEvolution}">
                                                                            <f:convertDateTime pattern="MMMMM" />
                                                                        </h:outputText>
                                                                        <b>
                                                                            <h:outputText value="#{ev.dateEvolution}">
                                                                                <f:convertDateTime pattern="dd"/>
                                                                            </h:outputText>

                                                                        </b>
                                                                        <span>
                                                                            <h:outputText value="#{ev.dateEvolution}">
                                                                                <f:convertDateTime pattern="yyyy"/>
                                                                            </h:outputText>
                                                                        </span>
                                                                    </a>
                                                                </p>
                                                            </div>
                                                            <div class="grid_18">
                                                                <p:outputLabel value="Data:" styleClass="grid_4" rendered="false"/>
                                                                <p:calendar showOn="button" styleClass="grid_19" 
                                                                            value="#{ev.dateEvolution}" rendered="false"
                                                                            pattern="dd/MM/yyyy" locale="pt" required="true"/>
                                                                <div class="clear"></div>
                                                                <p:outputLabel value="Descrição" styleClass="grid_4"/>
                                                                <div class="clear"></div>
                                                                <div class="grid_23">
                                                                    <p:inputTextarea readonly="true" value="#{ev.descr}"/>
                                                                </div> 
                                                                <div class="clear"></div>
                                                            </div>
                                                            <div class="clear"/>
                                                        </ui:repeat>


                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showAnexos ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Anexos</h4>

                                                        <div class="container_24 clearfix">
                                                            <ui:repeat  value="#{r.annexs}" var="a">
                                                                <div class="grid_5">
                                                                    <h:outputLink  
                                                                        value="#{a.type ne 'application/pdf' ? 'viewImage.xhtml':'show'}" 
                                                                        title="#{a.description}"  target="_blank" >

                                                                        <div style="text-align: center; width: 20%;" class="grid_4">

                                                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                                                            style="margin-left:1%; width: 100px;"
                                                                                            url="show/?annex=#{a.id}" />

                                                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                                                     a.description.replace('.png','').replace(' ','_')}" 
                                                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                                                            style="margin-left:1%; width: 100px;" 
                                                                                            url="assets/images/pdf.jpeg" />


                                                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                                                     a.description.replace('.pdf','').replace(' ','_')}" 
                                                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>


                                                                        </div>
                                                                        <f:param name="annex" value="#{a.id}"/>
                                                                    </h:outputLink>
                                                                </div>
                                                                <div class="grid_18">
                                                                    <p:outputLabel value="Laudo" styleClass="left"/>
                                                                    <div class="clear"/>
                                                                    <div class="grid_23">
                                                                        <p:inputTextarea value="#{a.laudo}" />
                                                                    </div> 
                                                                </div> 
                                                                <div class="clear"/>

                                                            </ui:repeat>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                </div>

                                            </p:panel>
                                        </div>
                                    </ui:repeat>
                                </p:tab>
                            </p:tabView>
                        </div>
                    </p:panel>
                </p:dialog>

                <p:dialog id="dlgDoctorAgenda"  widgetVar="dlgDoctorDialogPesquisa"
                          header="Pesquisar Médico" modal="true" closeOnEscape="true"
                          width="800"  dynamic="true" > 

                    <p:ajax event="close" update="@form" listener="#{managerDiary.initDoctorPesquisa()}"/> 
                    <p:messages autoUpdate="true" closable="true"/>

                    <p:panel id="medicoAgendaPanelSearch" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">

                        <p:outputLabel value="Nome:" styleClass="grid_3"/>
                        <p:inputText styleClass="grid_20" value="#{managerDiary.doctorCreate.name}"/>

                        <div class="buttonAction">
                            <p:defaultCommand target="search-button-medico-agenda" />
                            <p:commandButton id="search-button-medico-agenda" value="Pesquisar" icon="ui-icon-search"
                                             update="medicoAgendaPanelSearch" process="medicoAgendaPanelSearch"
                                             actionListener="#{managerDiary.listDoctor()}"
                                             styleClass="ui-priority-primary" />
                        </div >

                        <p:dataTable var="dcta" id="doctorAgendaDataTable" value="#{managerDiary.doctors}"  
                                     selectionMode="single" rowKey="#{dcta.id}"
                                     selection="#{managerDiary.doctorPesquisaSelect}"
                                     emptyMessage="Nenhum registro encontrado" sortMode="multiple"
                                     paginatorPosition="bottom" paginator="true" rows="5"
                                     >
                            <f:facet name="header">
                                Médicos
                            </f:facet> 
                            <p:ajax event="rowSelect"  process="@this" update="@this"/>
                            <p:ajax event="rowUnselect"  process="@this" update="@this"/>

                            <p:column  headerText="Nome" >  
                                <h:outputText value="#{dcta.name}" />  
                            </p:column>

                            <p:column  headerText="CBO"  style="white-space: pre-wrap;" width="150">  
                                <h:outputText value="#{dcta.cbo.descr}" />  
                            </p:column>

                        </p:dataTable>
                        <p></p>
                        <div class="buttonAction">
                            <p:commandButton value="Selecionar" icon="ui-icon-search"
                                             update="@form, :diaryForm" process="@form"
                                             actionListener="#{managerDiary.selectDoctorAgendaDialog()}"
                                             oncomplete="dlgDoctorDialogPesquisa.hide();" />


                        </div>
                    </p:panel>
                </p:dialog>
                <p:dialog id="dlgDoctorRequest"  widgetVar="dlgDoctorRequestDialog"
                          header="Pesquisar Médico" modal="true"
                          width="800"  dynamic="true" > 
                    <p:ajax event="close" update=":formDialog:eventDetails, medicoRequestPanelSearch" 
                            immediate="true" listener="#{managerDiary.initDoctor()}" /> 

                    <p:messages autoUpdate="true" closable="true"/>

                    <p:panel id="medicoRequestPanelSearch" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">

                        <p:outputLabel value="Nome:" styleClass="grid_3"/>
                        <p:inputText styleClass="grid_20" value="#{managerDiary.doctorCreate.name}"/>

                        <div class="buttonAction">
                            <p:defaultCommand target="search-button-medicorequest" />
                            <p:commandButton id="search-button-medicorequest" value="Pesquisar" icon="ui-icon-search"
                                             update="medicoRequestPanelSearch" process="medicoRequestPanelSearch"
                                             actionListener="#{managerDiary.listDoctor()}"
                                             styleClass="ui-priority-primary" />
                        </div >

                        <p:dataTable var="dct" id="doctorRequestDataTable" value="#{managerDiary.doctors}"  
                                     selectionMode="single" rowKey="#{dct.id}"
                                     selection="#{managerDiary.doctorRequestSelect}"
                                     emptyMessage="Nenhum registro encontrado" sortMode="multiple"
                                     paginatorPosition="bottom" paginator="true" rows="5"
                                     >
                            <f:facet name="header">
                                Médicos
                            </f:facet> 
                            <p:ajax event="rowSelect"  process="@this" update="@this"/>
                            <p:ajax event="rowUnselect"  process="@this" update="@this"/>
                            <p:column  headerText="Nome"  style="white-space: pre-wrap;" >  
                                <h:outputText value="#{dct.name}" />  
                            </p:column>
                            <p:column  headerText="CBO" width="150" >  
                                <h:outputText value="#{dct.cbo.descr}" />  
                            </p:column>


                        </p:dataTable>

                        <div class="buttonAction">
                            <p:commandButton value="Selecionar" icon="ui-icon-search"
                                             update="@this, :formDialog:eventDetails" 
                                             process="@this, :formDialog:eventDetails" 
                                             actionListener="#{managerDiary.selectDoctorRequestDialog()}"
                                             oncomplete="dlgDoctorRequestDialog.hide();" />


                        </div>
                    </p:panel>
                </p:dialog>

                <p:dialog id="dlgDoctor"  widgetVar="dlgDoctorDialog"
                          header="Pesquisar Médico" modal="true"
                          width="800"  dynamic="true" > 
                    <p:ajax event="close" update=":formDialog:eventDetails, medicoPanelSearch" listener="#{managerDiary.initDoctor()}"/> 
                    <p:messages autoUpdate="true" closable="true"/>

                    <p:panel id="medicoPanelSearch" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">

                        <p:outputLabel value="Nome:" styleClass="grid_3"/>
                        <p:inputText styleClass="grid_20" value="#{managerDiary.doctorCreate.name}"/>

                        <div class="buttonAction">
                            <p:defaultCommand target="search-button-medico" />
                            <p:commandButton id="search-button-medico" value="Pesquisar" icon="ui-icon-search"
                                             update="medicoPanelSearch" process="medicoPanelSearch"
                                             actionListener="#{managerDiary.listDoctor()}"
                                             styleClass="ui-priority-primary" />
                        </div >

                        <p:dataTable var="dct" id="doctorDataTable" value="#{managerDiary.doctors}"  
                                     selectionMode="single" rowKey="#{dct.id}"
                                     selection="#{managerDiary.doctorSelectDialog}"
                                     emptyMessage="Nenhum registro encontrado" sortMode="multiple"
                                     paginatorPosition="bottom" paginator="true" rows="5"
                                     >
                            <f:facet name="header">
                                Médicos
                            </f:facet> 
                            <p:ajax event="rowSelect"  process="@this" update="@this"/>
                            <p:ajax event="rowUnselect"  process="@this" update="@this"/>

                            <p:column  headerText="Nome" >  
                                <h:outputText value="#{dct.name}" />  
                            </p:column>

                            <p:column  headerText="CBO"  style="white-space: pre-wrap;" width="150">  
                                <h:outputText value="#{dct.cbo.descr}" />  
                            </p:column>

                        </p:dataTable>
                        <p></p>
                        <div class="buttonAction">
                            <p:commandButton value="Selecionar" icon="ui-icon-search"
                                             update="@this, :formDialog:eventDetails" 
                                             process="@this, :formDialog:eventDetails"
                                             actionListener="#{managerDiary.selectDoctorDialog()}"
                                             oncomplete="dlgDoctorDialog.hide();" />


                        </div>
                    </p:panel>
                </p:dialog>
                <p:dialog id="dlgProcedure"  widgetVar="dlgProcedureDialog"
                          header="Pesquisar Procedimento" modal="true"
                          width="800"  dynamic="true" resizable="false"> 
                    <p:ajax event="close" update=":formDialog:eventDetails, procedurePanelSearch" listener="#{managerDiary.initProcedure()}" /> 
                    <p:messages autoUpdate="true" closable="true"/>

                    <p:panel id="procedurePanelSearch" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">

                        <p:outputLabel value="Cód:" styleClass="grid_3"/>
                        <p:inputText styleClass="grid_3" value="#{managerDiary.procedureSearch.cod}"/>
                        <p:outputLabel value="Nome:" styleClass="grid_2"/>
                        <p:inputText styleClass="grid_14" value="#{managerDiary.procedureSearch.name}"/>
                        <div class="clear"/>
                        <div class="buttonAction">
                            <p:defaultCommand target="search-button-procedure" />
                            <p:commandButton id="search-button-procedure" value="Pesquisar" icon="ui-icon-search"
                                             update="procedurePanelSearch" process="procedurePanelSearch"
                                             actionListener="#{managerDiary.listProcedure()}"
                                             styleClass="ui-priority-primary" />
                        </div >

                        <p:dataTable id="tablePro" var="p" value="#{managerDiary.procedures}" 
                                     styleClass="grid_24"
                                     rowIndexVar="rowid"
                                     rowKey="#{p.id}"
                                     rows="5" paginator="true"  
                                     paginatorPosition="bottom"
                                     selectionMode="single"
                                     selection="#{managerDiary.procedureSelectDialog}"
                                     emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                Procedimentos
                            </f:facet>
                            <p:ajax event="rowSelect"  process="@this" update="@this"/>
                            <p:ajax event="rowUnselect"  process="@this" update="@this"/>
                            <p:column headerText="Cod">  
                                <h:outputText value="#{p.cod}"/>
                            </p:column>  
                            <p:column headerText="Nome">  
                                <h:outputText value="#{p.name}"/>
                            </p:column>
                            <p:column headerText="Duração">  
                                <h:outputText value="#{p.duration}"/>
                            </p:column>
                        </p:dataTable> 

                        <div class="buttonAction">
                            <p:commandButton value="Selecionar" icon="ui-icon-search"
                                             update="@this, :formDialog:eventDetails" 
                                             process="@this, :formDialog:eventDetails" 
                                             actionListener="#{managerDiary.selectProcedureDialog()}"
                                             oncomplete="dlgProcedureDialog.hide();" />


                        </div>
                    </p:panel>
                </p:dialog>


                <p:dialog id="dlgProcedureRetorno"  widgetVar="retornoDialog"
                          header="Retorno" modal="true"
                          width="800"  dynamic="true" >
                    <p:messages autoUpdate="true" closable="true"/>

                    <p:panel id="procedureRetornoPanel" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">

                        <p:dataTable id="tableRetorno" var="dr" value="#{managerDiary.diarysRetorno}" 
                                     styleClass="grid_24"
                                     rowIndexVar="rowid"
                                     rowKey="#{dr.id}"
                                     rows="5" paginator="true"  
                                     paginatorPosition="bottom"
                                     selection="#{managerDiary.diary.retornoDiary}"
                                     selectionMode="single"
                                     emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                Atendimentos Anteriores
                            </f:facet>
                            <p:ajax event="rowSelect"  process="@this" update="@this"/>
                            <p:ajax event="rowUnselect"  process="@this" update="@this"/>
                            <p:column headerText="Data">  
                                <h:outputText value="#{dr.dateConsultation}">
                                    <f:convertDateTime pattern="dd/MM/yyy HH:mm:ss "  locale="pt"/>
                                </h:outputText>
                            </p:column>  
                            <p:column headerText="Procedimento">  
                                <h:outputText value="#{dr.procedure.name}"/>
                            </p:column>
                            <p:column headerText="Convênio">  
                                <h:outputText value="#{dr.operator.name}"/>
                            </p:column>
                            <p:column headerText="Médico">  
                                <h:outputText value="#{dr.doctor.name}"/>
                            </p:column>
                        </p:dataTable> 

                        <div class="buttonAction">
                            <p:commandButton value="Selecionar" icon="ui-icon-search"
                                             update="@this, :formDialog:eventDetails" 
                                             actionListener="#{managerDiary.selectRetorno()}"
                                             process="@this" 
                                             oncomplete="retornoDialog.hide();" />

                        </div>
                    </p:panel>
                </p:dialog>

                <p:dialog id="dlgOperator"  widgetVar="dlgOperatorDialog"
                          header="Selecionar Convênio" modal="true"
                          width="800"  dynamic="true" > 

                    <p:ajax event="close" update=":formDialog:eventDetails, operatorPanelSearch" 
                            listener="#{managerDiary.initDoctor()}"/>

                    <p:messages autoUpdate="true" closable="true"/>

                    <p:panel id="operatorPanelSearch" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">


                        <p:dataTable var="opt" id="operatorDataTable" 
                                     value="#{managerDiary.operators}"  
                                     emptyMessage="Nenhum registro encontrado" 
                                     paginatorPosition="bottom" paginator="true" rows="10"
                                     rowKey="#{opt.id}" selection="#{managerDiary.operatorSelect}"
                                     selectionMode="single">
                            <f:facet name="header">
                                Convênios
                            </f:facet> 
                            <p:ajax event="rowSelect"  process="@this" update="@this"/>
                            <p:ajax event="rowUnselect"  process="@this" update="@this"/>
                            <p:column  headerText="Descrição"  style="white-space: pre-wrap;"  >  
                                <h:outputText value="#{opt.name}" />  
                            </p:column>
                            <p:column  headerText="ANS" >  
                                <h:outputText value="#{opt.ans}" />  
                            </p:column>

                        </p:dataTable>

                        <div class="buttonAction">
                            <p:commandButton value="Selecionar" icon="ui-icon-search"
                                             update="@this, :formDialog:eventDetails" 
                                             process="@this, :formDialog:eventDetails"
                                             actionListener="#{managerDiary.selectOperator()}"
                                             oncomplete="dlgOperatorDialog.hide();" />
                        </div>
                    </p:panel>
                </p:dialog>

                <p:dialog id="dlgCustomer"  widgetVar="dlgCustomerDialog"
                          header="Paciente"  dynamic="true" appendToBody="false" modal="true"
                          resizable="false"
                          width="900"  height="500" > 
                    <p:ajax event="close" listener="#{managerDiary.initCustomer()}" 
                            update=":formDialog:tabViewCustomer:customerPrimarySearch, :formDialog:tabViewCustomer:customerPrimaryAdd,
                            :formDialog:tabViewCustomer:customerPrimaryEdit,
                            :formDialog:eventDetails, :formDialog:tabViewCustomer" /> 
                    <p:messages autoUpdate="true" closable="true"/>
                    <p:tabView id="tabViewCustomer" widgetVar="wgvTabViewCustomer">
                        <p:tab title="Pesquisar">
                            <p:panel id="customerPrimarySearch" 
                                     style="background: none; border: none;" 
                                     styleClass="container_24 clearfix ">

                                <div class="grid_24">
                                    <p:outputLabel for="nameSearch" value="Nome:" styleClass="grid_3"/>
                                    <p:inputText id="nameSearch" styleClass="grid_20" value="#{managerDiary.customerSearch.name}"/>
                                    <p:outputLabel for="cpfSearch" value="CPF:" styleClass="grid_3"/>
                                    <p:inputMask id="cpfSearch" mask="999.999.999-99" styleClass="grid_8" value="#{managerDiary.customerSearch.cpf}"/>
                                    <div class="clear"></div>

                                    <div class="buttonAction">
                                        <p:defaultCommand target="search-button" />
                                        <p:commandButton id="search-button" value="Pesquisar" icon="ui-icon-search"
                                                         update="customerPrimarySearch" process="customerPrimarySearch" 
                                                         actionListener="#{managerDiary.searchCustomer()}"
                                                         styleClass="ui-priority-primary" />
                                    </div>
                                </div>

                                <p:dataTable id="tablePac" var="pac" value="#{managerDiary.searchCustomers}" 
                                             styleClass="grid_24"
                                             rowIndexVar="rowid"
                                             rowKey="#{pac.id}"
                                             rows="5" paginator="true"  
                                             paginatorPosition="bottom"
                                             selection="#{managerDiary.customerSelect}"
                                             selectionMode="single"

                                             emptyMessage="Nenhum registro">  
                                    <f:facet name="header">
                                        Pacientes
                                    </f:facet>
                                    <p:ajax event="rowSelect"  process="@this" update="@this"/>
                                    <p:ajax event="rowUnselect"  process="@this" update="@this"/>
                                    <p:column headerText="Nome" width="400">  
                                        <h:outputText value="#{pac.name}"/>
                                    </p:column>  
                                    <p:column headerText="CPF" width="150">  
                                        <h:outputText value="#{pac.cpf}"/>
                                    </p:column>
                                    <p:column headerText="Contato" width="150">  
                                        <h:outputText value="#{pac.cellular}"/>
                                    </p:column>


                                </p:dataTable> 
                                <div class="buttonAction">

                                    <p:commandButton value="Selecionar" icon="ui-icon-search"   
                                                     update=":formDialog:eventDetails" 
                                                     process="@this, tablePac" 
                                                     actionListener="#{managerDiary.selectCustomer()}"
                                                     immediate="false" oncomplete="dlgCustomerDialog.hide();" />
                                </div>
                            </p:panel>
                        </p:tab>
                        <p:tab id="addCustomer" title="Adicionar" style="height:350px;">
                            <p:panel id="customerPrimaryAdd" style="background: none; border: none; " 
                                     styleClass="container_24 clearfix " >

                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Dados Gerais</h4></legend>
                                    <p:panel id="customerPrimaryData" style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">

                                        <div class="grid_19">
                                            <p:outputLabel for="name" value="Nome :" 
                                                           style="margin-right: -3px; margin-left: 15px" styleClass="grid_3"/>
                                            <p:inputText id="name" required="true" styleClass="grid_20"
                                                         value="#{managerDiary.customerCreate.name}"/>

                                            <p:outputLabel for="dataNasc" value="Nascimento:" styleClass="grid_3" 
                                                           style="margin-left: -6px;"/>
                                            <p:calendar id="dataNasc" showOn="button" style=" width: 30.5%; margin-left: 18px; "  
                                                        styleClass="grid_7"
                                                        pattern="dd/MM/yyyy" locale="pt"
                                                        value="#{managerDiary.customerCreate.dateBirth}"/>

                                            <p:outputLabel for="email" value="E-mail :" style="margin-left: 13px;" styleClass="grid_3"/>
                                            <p:inputText id="email" styleClass="grid_8" style=" margin-left: 6px; width: 35.5%"
                                                         value="#{managerDiary.customerCreate.email}"/>

                                            <div class="clear"></div>

                                            <p:outputLabel value="Telefone :" styleClass="grid_3"/>
                                            <p:inputMask  mask="(99) 9999-9999" styleClass="grid_8" value="#{managerDiary.customerCreate.phone}"/>

                                            <p:outputLabel  value="Celular :" style="margin-left: -3px" styleClass="grid_3"/>
                                            <p:inputMask  mask="(99) 9999-9999" styleClass="grid_8" style="width: 35.5%" value="#{managerDiary.customerCreate.cellular}"/>

                                            <div class="clear"></div>

                                            <p:outputLabel value="Estado Civil :" styleClass="grid_4" style="margin-left: -20px"/>
                                            <div class="grid_8">
                                                <p:selectOneMenu style="width: 105.5%; height: 21px;"  value="#{managerDiary.customerCreate.civilStatus}">  
                                                    <f:selectItem itemLabel="" itemValue="" />  
                                                    <f:selectItems value="#{managerCustomer.selectCivilStatus()}" />  
                                                </p:selectOneMenu> 
                                            </div>
                                            <p:outputLabel value="Sexo : " styleClass="grid_3"/>
                                            <div class="grid_8">
                                                <p:selectOneMenu style="width: 117.5%; height: 21px;" panelStyle="width:150px;" value="#{managerDiary.customerCreate.gender}" >   
                                                    <f:selectItem itemLabel="" itemValue="" />  
                                                    <f:selectItems value="#{managerCustomer.gender}" />  
                                                </p:selectOneMenu> 
                                            </div>



                                        </div>
                                        <div class="grid_5" style="text-align: center;">
                                            <p:panel id="avatar" style="background: none; border: none;" 
                                                     styleClass="container_24 clearfix ">
                                                <p:graphicImage id="avatar1" styleClass="image grid_3" 
                                                                style="margin-left:1%; width: 120px;" 
                                                                alt="#{managerDiary.customerCreate.annex.id}" title="#{managerDiary.customerCreate.annex.id}"
                                                                url="#{managerDiary.customerCreate.annex.id eq null ? '':'show/?annex='}#{managerDiary.customerCreate.annex.id eq null ? 'assets/images/avatar.jpg': managerDiary.customerCreate.annex.id}" />
                                                <div class="clear"></div>

                                                <p:commandButton value="Capturar" icon="ui-icon-image" onclick="capt.show();"  
                                                                 process="@this" update="@this, :formDialog:imagePanel"
                                                                 styleClass="grid_23" actionListener="#{managerDiary.photoCreate()}"/>

                                                <p:remoteCommand name="updateavatar" process="@this" update="avatar1" />
                                            </p:panel>


                                        </div>
                                    </p:panel>

                                </fieldset>
                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Dados Complementares</h4></legend>
                                    <p:panel id="customerSecundary" style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">
                                        <p:outputLabel value="CPF :" styleClass="grid_3"/>

                                        <p:inputMask id="cpfMask" mask="999.999.999-99" styleClass="grid_8" 
                                                     value="#{managerDiary.customerCreate.cpf}">
                                            <p:ajax event="blur" process="@this, cpfMask" 
                                                    update="cpfMask"
                                                    listener="#{managerDiary.exist()}" />
                                        </p:inputMask>

                                        <p:outputLabel value="RG :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerCreate.rg}"/>

                                        <p:outputLabel value="Profissão :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_20" style="width: 82.3%" value="#{managerDiary.customerCreate.occupation}"/>

                                        <p:outputLabel value="Mãe :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerCreate.filiationMother}"/>
                                        <p:outputLabel value="Profissão :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerCreate.occupationMother}"/>
                                        <div class="clear"/>
                                        <p:outputLabel value="Pai :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerCreate.filiationFather}"/>
                                        <p:outputLabel value="Profissão :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerCreate.occupationFather}"/>
                                        <div class="clear"/>
                                        <p:outputLabel value="Responsável:" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_20" style="width: 82.3%" value="#{managerDiary.customerCreate.responsible}"/>

                                    </p:panel>
                                </fieldset>
                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Endereço</h4></legend>
                                    <p:panel id="address" style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">

                                        <p:outputLabel value="CEP :" styleClass="grid_3" />
                                        <p:inputMask mask="99.999-999" styleClass="grid_8" value="#{managerDiary.address.zipcode}" />

                                        <div class="clear"/>
                                        <p:outputLabel value="Logradouro :" styleClass="grid_3" />
                                        <p:inputText styleClass="grid_20" style="width: 82.5%" value="#{managerDiary.address.publicPark}" />
                                        <div class="clear"/>
                                        <p:outputLabel value="Bairro :" styleClass="grid_3" />
                                        <p:inputText  styleClass="grid_8" value="#{managerDiary.address.neighborhood}" />

                                        <p:outputLabel value="Complemento :" styleClass="grid_4" />
                                        <p:inputText styleClass="grid_8"  value="#{managerDiary.address.complement}" />
                                        <div class="clear"/>
                                        <p:outputLabel value="Nº :" styleClass="grid_3" />
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.address.number}" />

                                        <p:outputLabel  value="Cidade :" styleClass="grid_4"  />
                                        <p:autoComplete value="#{managerDiary.city}" style="width: 28.5%" var="cityValue" 
                                                        completeMethod="#{managerCity.autocomplete}"
                                                        itemLabel="#{cityValue.name.toString().concat(' - ')}#{cityValue.country.sgl}" itemValue="#{cityValue}" 
                                                        scrollHeight="200" forceSelection="true"
                                                        styleClass="grid_7" dropdown="true"
                                                        converter="#{autocompleteconverter}" /> 
                                    </p:panel>
                                </fieldset>
                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Plano de Saúde</h4></legend>
                                    <p:panel style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">
                                        <p:outputLabel value="Operadora :" styleClass="grid_3"/>
                                        <p:autoComplete value="#{managerDiary.operatorCreate}" style="width: 79.5%" 
                                                        completeMethod="#{managerOperator.autocomplete}"  
                                                        var="o" itemLabel="#{o.name}" itemValue="#{o}" 
                                                        styleClass="grid_19" dropdown="true"
                                                        converter="#{autocompleteconverter}" />
                                        <div class="clear"/>
                                        <p:outputLabel value="Nº Carteira :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerCreate.cardNumber}"/>

                                        <p:outputLabel value="Validade :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerCreate.validateCard}"/>

                                    </p:panel>
                                </fieldset>
                                <f:facet name="footer">
                                    <div class="buttonAction">
                                        <p:commandButton value="Salvar" icon="ui-icon-disk"
                                                         process="customerPrimaryAdd"
                                                         update="customerPrimaryAdd"
                                                         actionListener="#{managerDiary.save()}"
                                                         styleClass="ui-priority-primary" />
                                        <p:button value="Cancelar"  icon="ui-icon-arrowreturnthick-1-w" />
                                    </div >
                                </f:facet>

                            </p:panel>
                        </p:tab>

                        <p:tab id="editCustomer" rendered="#{managerDiary.customerEdit.id ne null}" title="Editar" 
                               style="height:350px;">
                            <p:panel id="customerPrimaryEdit" style="background: none; border: none; " 
                                     styleClass="container_24 clearfix " >

                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Dados Gerais</h4></legend>
                                    <p:panel id="customerPrimaryDataEdit" style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">


                                        <div class="grid_19">

                                            <p:outputLabel for="nameEdit" value="Nome :" 
                                                           style="margin-right: -3px; margin-left: 15px" styleClass="grid_3"/>
                                            <p:inputText id="nameEdit" required="true" styleClass="grid_20" 
                                                         value="#{managerDiary.customerEdit.name}"/>                                            

                                            <p:outputLabel for="dataNascEdit" value="Nascimento:" styleClass="grid_3"
                                                           style="margin-left: -6px;"/>
                                            <p:calendar id="dataNascEdit" showOn="button"  style=" width: 30.5%; margin-left: 18px; "    styleClass="grid_7"
                                                        pattern="dd/MM/yyyy" locale="pt"
                                                        value="#{managerDiary.customerEdit.dateBirth}"/>

                                            <p:outputLabel for="emailEdit" value="E-mail :" style="margin-left: 13px;" styleClass="grid_3"/>
                                            <p:inputText id="emailEdit" styleClass="grid_8" style=" margin-left: 6px; width: 35.5%"
                                                         value="#{managerDiary.customerEdit.email}"/>

                                            <div class="clear"></div>

                                            <p:outputLabel for="phoneEdit" value="Telefone :" styleClass="grid_3"/>
                                            <p:inputMask id="phoneEdit" mask="(99) 9999-9999" styleClass="grid_8" 
                                                         value="#{managerDiary.customerEdit.phone}"/>

                                            <p:outputLabel for="cellularEdit" value="Celular :" style="margin-left: -3px" styleClass="grid_3"/>
                                            <p:inputMask id="cellularEdit" mask="(99) 9999-9999" styleClass="grid_8" 
                                                         style="width: 35.5%" value="#{managerDiary.customerEdit.cellular}"/>

                                            <div class="clear"></div>

                                            <p:outputLabel value="Estado Civil :" styleClass="grid_4" style="margin-left: -20px"/>
                                            <div class="grid_8">
                                                <p:selectOneMenu style="width: 105.5%; height: 21px;"  
                                                                 value="#{managerDiary.customerEdit.civilStatus}">  
                                                    <f:selectItem itemLabel="" itemValue="" />  
                                                    <f:selectItems value="#{managerCustomer.selectCivilStatus()}" />  
                                                </p:selectOneMenu> 
                                            </div>
                                            <p:outputLabel value="Sexo : " styleClass="grid_3"/>
                                            <div class="grid_8">
                                                <p:selectOneMenu style="width: 117.5%; height: 21px;" panelStyle="width:150px;"
                                                                 value="#{managerDiary.customerEdit.gender}" >   
                                                    <f:selectItem itemLabel="" itemValue="" />  
                                                    <f:selectItems value="#{managerCustomer.gender}" />  
                                                </p:selectOneMenu> 
                                            </div>



                                        </div>
                                        <div class="grid_5" style="text-align: center;">
                                            <p:panel id="avatarEdit" style="background: none; border: none;" 
                                                     styleClass="container_24 clearfix ">
                                                <p:graphicImage id="avatar1Edit" styleClass="image grid_3" 
                                                                style="margin-left:1%; width: 120px;" 
                                                                alt="#{managerDiary.customerEdit.annex.id}" 
                                                                title="#{managerDiary.customerEdit.annex.id}"
                                                                url="#{managerDiary.customerEdit.annex.id eq null ? '':'show/?annex='}
                                                                #{managerDiary.customerEdit.annex.id eq null ? 'assets/images/avatar.jpg':
                                                                  managerDiary.customerEdit.annex.id}" />
                                                <div class="clear"></div>

                                                <p:commandButton value="Capturar" icon="ui-icon-image" oncomplete="capt.show();"  
                                                                 process="@this" update="@this, :formDialog:imagePanel"
                                                                 actionListener="#{managerDiary.photoEdit()}" immediate="true"
                                                                 styleClass="grid_23" />

                                            </p:panel>


                                        </div>
                                    </p:panel>

                                </fieldset>
                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Dados Complementares</h4></legend>
                                    <p:panel id="customerSecundaryEdit" style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">
                                        <p:outputLabel value="CPF :" styleClass="grid_3"/>

                                        <p:inputMask id="cpfMaskEdit" mask="999.999.999-99" styleClass="grid_8" 
                                                     value="#{managerDiary.customerEdit.cpf}">
                                            <p:ajax event="blur" process="@this, cpfMaskEdit" 
                                                    update="cpfMaskEdit"
                                                    listener="#{managerDiary.exist()}" />
                                        </p:inputMask>

                                        <p:outputLabel value="RG :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerEdit.rg}"/>

                                        <p:outputLabel value="Profissão :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_20" style="width: 82.3%" 
                                                     value="#{managerDiary.customerEdit.occupation}"/>

                                        <p:outputLabel value="Mãe :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerEdit.filiationMother}"/>
                                        <p:outputLabel value="Profissão :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerEdit.occupationMother}"/>
                                        <div class="clear"/>
                                        <p:outputLabel value="Pai :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerEdit.filiationFather}"/>
                                        <p:outputLabel value="Profissão :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerEdit.occupationFather}"/>
                                        <div class="clear"/>
                                        <p:outputLabel value="Responsável:" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_20" style="width: 82.3%" 
                                                     value="#{managerDiary.customerEdit.responsible}"/>

                                    </p:panel>
                                </fieldset>
                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Endereço</h4></legend>
                                    <p:panel id="addressEdit" style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">

                                        <p:outputLabel value="CEP :" styleClass="grid_3" />
                                        <p:inputMask mask="99.999-999" styleClass="grid_8" value="#{managerDiary.address.zipcode}" />

                                        <div class="clear"/>
                                        <p:outputLabel value="Logradouro :" styleClass="grid_3" />
                                        <p:inputText styleClass="grid_20" style="width: 82.5%" value="#{managerDiary.address.publicPark}" />
                                        <div class="clear"/>
                                        <p:outputLabel value="Bairro:" styleClass="grid_3" />
                                        <p:inputText  styleClass="grid_8" value="#{managerDiary.address.neighborhood}" />
                                        <p:outputLabel value="Complemento :" styleClass="grid_4" />
                                        <p:inputText styleClass="grid_8"  value="#{managerDiary.address.complement}" />
                                        <div class="clear"/>
                                        <p:outputLabel value="Nº:" styleClass="grid_3" />
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.address.number}" />

                                        <p:outputLabel  value="Cidade :" styleClass="grid_4"  />
                                        <p:autoComplete value="#{managerDiary.city}" style="width: 28.5%" var="cityValue" 
                                                        completeMethod="#{managerCity.autocomplete}"
                                                        itemLabel="#{cityValue.name.toString().concat(' - ')}#{cityValue.country.sgl}" itemValue="#{cityValue}" 
                                                        scrollHeight="200" forceSelection="true"
                                                        styleClass="grid_7" dropdown="true"
                                                        converter="cityconverter" > 
                                            <f:ajax  />
                                        </p:autoComplete>
                                    </p:panel>
                                </fieldset>
                                <fieldset>
                                    <legend style="padding: 2px 12px;"> <h4 style="margin:0 0 10px 0">Plano de Saúde</h4></legend>
                                    <p:panel style="background: none; border: none;" 
                                             styleClass="container_24 clearfix ">
                                        <p:outputLabel value="Operadora :" styleClass="grid_3"/>
                                        <p:autoComplete value="#{managerDiary.operatorEdit}" style="width: 79.5%" 
                                                        completeMethod="#{managerOperator.autocomplete}"  
                                                        var="o" itemLabel="#{o.name}" itemValue="#{o}" 
                                                        styleClass="grid_19" dropdown="true"
                                                        converter="#{autocompleteconverter}" />
                                        <div class="clear"/>
                                        <p:outputLabel value="Nº Carteira :" styleClass="grid_3"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerEdit.cardNumber}"/>

                                        <p:outputLabel value="Validade :" styleClass="grid_4"/>
                                        <p:inputText styleClass="grid_8" value="#{managerDiary.customerEdit.validateCard}"/>

                                    </p:panel>
                                </fieldset>
                                <f:facet name="footer">
                                    <div class="buttonAction">
                                        <p:commandButton value="Atualizar" icon="ui-icon-disk"
                                                         process="customerPrimaryEdit, addressEdit"
                                                         update="customerPrimaryEdit, addressEdit"
                                                         actionListener="#{managerDiary.update()}"
                                                         styleClass="ui-priority-primary" />
                                        <p:button value="Cancelar"  icon="ui-icon-arrowreturnthick-1-w" />
                                    </div >
                                </f:facet>

                            </p:panel>
                        </p:tab>

                    </p:tabView>

                </p:dialog>


                <p:dialog id="image" dynamic="true" header="Captura de Imagem" modal="true" widgetVar="capt">  
                    <p:panel id="imagePanel" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">
                        <p:photoCam id="pcPhoto" widgetVar="pc" 
                                    update="#{managerDiary.photoedit ? ':formDialog:tabViewCustomer:avatar1Edit':':formDialog:tabViewCustomer:avatar1'}"
                                    listener="#{managerDiary.capture}"/>
                        <div class="clear"></div>
                        <p:commandButton value="Capturar" onclick="pc.capture();"
                                         process="@this" update="@this" icon="ui-icon-check"
                                         styleClass="grid_24" oncomplete="capt.hide();#{managerDiary.photoedit ? 'updatePhotoEdit();':'updatePhoto();'} "/>

                        <p:remoteCommand name="updatePhoto" process="@this" 
                                         update=":formDialog:tabViewCustomer:avatar1, pcPhoto">
                        </p:remoteCommand>

                        <p:remoteCommand name="updatePhotoEdit" process="@this" 
                                         update=":formDialog:tabViewCustomer:avatar1Edit, pcPhoto">
                        </p:remoteCommand>

                    </p:panel>
                </p:dialog>

                <p:confirmDialog width="350" closable="false"
                                 message="O CPF informado encontra-se registrado na base, deseja utilizá-lo ?" 
                                 header="CPF já cadastrado" id="customerDlg" widgetVar="customerDlg">
                    <div style="text-align: center;margin: 8px">
                        <p:commandButton icon="ui-icon-check" value="Sim" 
                                         action="#{managerDiary.loadCustomer()}" 
                                         id="yes" process="@this" update="@form"  />
                        <p:commandButton icon="ui-icon-close" value="Não"
                                         action="#{managerDiary.clearCpf()}" 
                                         oncomplete="customerDlg.hide()"
                                         process="@this" update=":formDialog:tabViewCustomer:cpfMask" />
                    </div>
                </p:confirmDialog>
            </h:form>

            <script type="text/javascript">
                PrimeFaces.locales['pt'] = {  
                    closeText: 'Fechar',  
                    prevText: 'Anterior',  
                    nextText: 'Próximo',  
                    currentText: 'Começo',  
                    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],  
                    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun', 'Jul','Ago','Set','Out','Nov','Dez'],  
                    dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],  
                    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],  
                    dayNamesMin: ['D','S','T','Q','Q','S','S'],  
                    weekHeader: 'Semana',  
                    firstDay: 1,  
                    isRTL: false,  
                    showMonthAfterYear: false,  
                    yearSuffix: '',  
                    timeOnlyTitle: 'Só Horas',  
                    timeText: 'Tempo',  
                    hourText: 'Hora',  
                    minuteText: 'Minuto',  
                    secondText: 'Segundo',  
                    currentText: 'Data Atual',  
                    ampm: true,  
                    month: 'Mês',  
                    week: 'Semana',  
                    day: 'Dia',  
                    allDayText : 'Todo Dia'  
                };  
            </script>

        </ui:define>
    </ui:composition>

</html>
